'''
Created on May 1, 2012

@author: mshen
'''
import wx
from datetime import datetime

class CreateTopicDialog(wx.Dialog):
    
    def __init__(self, parent):
        super(CreateTopicDialog, self).__init__(parent=parent, title="Create Charity", size=(300, 300))
        self.parent = parent
        self.vbox = wx.BoxSizer(wx.VERTICAL)
#        panel.SetSizer(vbox)
#        sb = wx.StaticBox(panel, label='Colors')
#        sbs = wx.StaticBoxSizer(sb, orient=wx.VERTICAL)        
#        sbs.Add(wx.RadioButton(panel, label=parent.string, style=wx.RB_GROUP))
#        sbs.Add(wx.RadioButton(panel, label='16 Colors'))
#        sbs.Add(wx.RadioButton(panel, label='2 Colors'))
        
        self.hbox1 = wx.BoxSizer(wx.HORIZONTAL)        
        self.hbox1.Add(wx.StaticText(self, label = "Title: ", style = wx.ALIGN_LEFT, size=wx.Size(80,25)))
        self.hbox1.Add(wx.TextCtrl(self , size=wx.Size(125,25)), flag=wx.LEFT)
        self.hbox2 = wx.BoxSizer(wx.HORIZONTAL)        
        self.hbox2.Add(wx.StaticText(self, label = "Description: ", style = wx.ALIGN_LEFT , size=wx.Size(80,75)))
        self.hbox2.Add(wx.TextCtrl(self, style = wx.TE_MULTILINE, size=wx.Size(200,75)), flag=wx.LEFT)
        self.hbox5 = wx.BoxSizer(wx.HORIZONTAL)        
        self.hbox5.Add(wx.StaticText(self, label = "Community: ", style = wx.ALIGN_LEFT, size=wx.Size(80,25)))
        self.hbox5.Add(wx.TextCtrl(self, size=wx.Size(125,25)), flag=wx.LEFT)
        self.hbox6 = wx.BoxSizer(wx.HORIZONTAL)        
        self.hbox6.Add(wx.StaticText(self, label = "User: ", style = wx.ALIGN_LEFT, size=wx.Size(80,25)))
        self.hbox6.Add(wx.TextCtrl(self, size=wx.Size(125,25)), flag=wx.LEFT)
        
        self.vbox.Add(self.hbox1)
        self.vbox.Add(self.hbox2)
        self.vbox.Add(self.hbox5)
        self.vbox.Add(self.hbox6)
   
       
        self.hbox8 = wx.BoxSizer(wx.HORIZONTAL)
        okButton = wx.Button(self, label='Ok')
        closeButton = wx.Button(self, label='Close')
        self.hbox8.Add(okButton)
        self.hbox8.Add(closeButton, flag=wx.LEFT, border=5)

#        vbox.Add(panel, proportion=1, flag=wx.ALL|wx.EXPAND, border=5)
        self.vbox.Add(self.hbox8, flag= wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, border=10)

        mainBox = wx.BoxSizer(wx.HORIZONTAL)
        mainBox.Add(self.vbox)
        self.SetSizer(mainBox)
        
        okButton.Bind(wx.EVT_BUTTON, self.OnOK)
        closeButton.Bind(wx.EVT_BUTTON, self.OnClose)
        
    def OnClose(self, e):
        self.Destroy()
        
    def OnOK(self, e):
        self.parent.topic.setTitle(self.hbox1.GetItem(1).GetWindow().GetValue())
        self.parent.topic.setDescription(self.hbox2.GetItem(1).GetWindow().GetValue())
        self.parent.topic.getIdentity().setCommunity(self.hbox5.GetItem(1).GetWindow().GetValue())
        self.parent.topic.getIdentity().setUser(self.hbox6.GetItem(1).GetWindow().GetValue())
        self.parent.topic.getIdentity().setDate(datetime.now())
        self.Destroy()
